/*  Army Editor for yALB - Yet Another List Builder (roster Editor for Wargames/tabletop games).
    Copyright (C) 2011  Daniel Ricardo Castro Alvarado

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.*/

#ifndef INHERITEDMANAGER_H
#define INHERITEDMANAGER_H

#include "structmanager.h"
#include <QTreeWidget>
#include <QComboBox>

class InheritedManager : public StructManager
{
    Q_OBJECT
public:

    InheritedManager(QTreeWidget* inheritTree = 0, QTreeWidget* unitTree = 0,
                     QTreeWidget *itemTree = 0, QTreeWidget* optionTree = 0,
                     StructManager *inheritanceManager = 0, QWidget *parent = 0);

    // Overriden functions (structManager)

    virtual bool addCategory(const GameCategory &category, const QString &key);
    virtual bool addColumn(const Column &column, const QString &key);
    virtual bool addProperty(const GameProperty &property, const QString &key);
    virtual bool addOption(const UnitOption &option, const QString &key);
    virtual bool addItem(const GameItem &item, const QString &key);
    virtual bool addGlobalText(const GlobalText &globalText, const QString &key);
    virtual void removeAll();

    // New virtual functions

    /*virtual void removeCategory(QTreeWidgetItem *item, bool messages = true,
                                bool deleteItem = true);
    virtual void removeOption(QTreeWidgetItem* item, bool messages = true,
                              bool deleteItem = true);
    virtual void removeItem(QTreeWidgetItem* item, bool messages = true,
                            bool deleteItem = true);
    virtual void removeGlobalText(int row);*/

    // Var management

    void setInheritTree(QTreeWidget *inheritTree);
    void setUnitTree(QTreeWidget *unitTree);
    void setItemTree(QTreeWidget *itemTree);
    void setOptionTree(QTreeWidget *optionTree);
    void setOptionCategories(QComboBox *optionCategories);
    void setItemCategories(QComboBox *itemCategories);
    void setUnitCategories(QComboBox *unitCategories);
    void setCategoryData(QHash<QString, QList<int> > *inheritedCategoriesData);
    void setItemData(QHash<QString, QList<int> > *inheritedItemsData);
    void setOptionData(QHash<QString, int> *inheritedOptionsData);
    void setInheritanceManager(StructManager *inheritanceManager);

protected:
    QTreeWidget *inheritTree;
    QTreeWidget *unitTree;
    QTreeWidget *itemTree;
    QTreeWidget *optionTree;
    QComboBox *optionCategories;
    QComboBox *itemCategories;
    QComboBox *unitCategories;
    QHash<QString, QList<int> > *inheritedCategoriesData;
    QHash<QString, QList<int> > *inheritedItemsData;
    QHash<QString, int> *inheritedOptionsData;
    StructManager *inheritanceManager; // For inheritance removal in removeAll()

private:
    QStringList propertyList; // Property ID list

    void removeCategoryItem(QTreeWidget* tree, int index, const QString& key);
    void removeCategoryItem(QTreeWidgetItem* parent, int index, const QString& key);
};

#endif // INHERITEDMANAGER_H
